@{
    Layout = "_LayoutAndSidebar";
}

<style>
    .page {
        height: 100%;
        overflow: auto;
        margin-bottom: unset !important;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    .page-toolbar {
        overflow: auto;
        box-sizing: border-box;
        padding: 8px 24px;
    }

    .page-content {
        flex: 1;
        overflow: auto;
        box-sizing: border-box;
        padding: 12px;
        display: flex;
    }

    #iframe_list {
        width: 100%;
    }
</style>

<div class="page">
    <div class="box page-toolbar">
        <nav class="level">
            <!-- Left side -->
            <div class="level-left">
                <div class="level-item">
                    <p class="subtitle is-5">
                        <strong>工厂业务管理</strong>
                    </p>
                </div>
            </div>

            <!-- Right side -->
            <div class="level-right">
                <div class="level-item">
                    <button class="button is-primary" id="button_useinvite">
                        <span class="icon">
                            <i class="fa-solid fa-link"></i>
                        </span>
                        <span>
                            使用邀请码
                        </span>
                    </button>
                </div>

            </div>
        </nav>
    </div>

    <div class="box page-content">
        <iframe src="~/iframe/FactoryListIFrame.html" frameborder="0" id="iframe_list"></iframe>
    </div>
    
</div>

<script>
    let E_btnUseInvite = document.querySelector('#button_useinvite');
    E_btnUseInvite.addEventListener('click', () => {
        let inviteCode = prompt('请输入邀请码');
        if(inviteCode == null || inviteCode == ''){
            return;
        }

        let url = '/Work/BindFactoryInvite';
        let data = {
            code: inviteCode
        };
        $.post(url, data, (res) => {
            if(res.code == 0){
                alert('成功绑定邀请码');
                window.location.reload();
            }else{
                alert(res.msg);
            }
        });
    });
</script>